﻿module lang.d.sts.declarations.daggregatedeclaration;

import lang.d.sts.declarations.ddeclaration;
import lang.d.sts.declarations.dimport;
import lang.d.sts.iaggregate;

abstract class DAggregateDeclaration: DDeclaration, IAggregate {
    protected DDeclaration[] myDeclarations;
    private DImport[][string] myImportedModules;

    public this(uint attribute) {
        super(attribute);
    }
    
    override public void addDeclaration(DDeclaration declaration) {
        myDeclarations ~= declaration;
        declaration.setParent(this);
    }

    override public void addImport(DImport imp) {
        string prefix = imp.getPrefix();
        if (prefix in myImportedModules) {
            myImportedModules[prefix] ~= imp;
        } else {
            myImportedModules[prefix] = [imp];
        }
        imp.setParent(this);
    }
    
    override public DImport[][string] getImportedModules() {
        return myImportedModules;
    }
    
    override public DDeclaration[] getDeclarations() {
        return myDeclarations;
    }
}